
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
    #region AreaPrice Model -(by fangyifeng at 2010-12-29 00:00:16)

    /// <summary>
    /// AreaPrice object'AreaPrice'.
    /// </summary>
    public class AreaPrice : System.IComparable
    {
        #region Member Variables

        protected Guid _id;
        protected decimal _fromWeight;
        protected decimal _toWeight;
        protected decimal _beginWeight;
        protected decimal _extraWeight;
        protected decimal _beginCost;
        protected decimal _extraCost;
        protected decimal _extraCharge;
        protected decimal _discount;
        protected decimal _RuelRate;
        protected short _areaNumber;
        protected ShipMethod _shipMethod;
        protected ShipCompany _shipCompany;

        protected static String _sortExpression = "Id";
        protected static SortDirection _sortDirection = SortDirection.Ascending;

        #endregion

        #region Constructors

        public AreaPrice() { }

        public AreaPrice(decimal ruelRate, decimal fromWeight, decimal toWeight, decimal beginWeight, decimal extraWeight, decimal beginCost, decimal extraCost, decimal extraCharge, decimal discount, short areaNumber, ShipMethod shipMethod, ShipCompany shipCompany)
        {
            _RuelRate = ruelRate;
            this._fromWeight = fromWeight;
            this._toWeight = toWeight;
            this._beginWeight = beginWeight;
            this._extraWeight = extraWeight;
            this._beginCost = beginCost;
            this._extraCost = extraCost;
            this._extraCharge = extraCharge;
            this._discount = discount;
            this._areaNumber = areaNumber;
            this._shipMethod = shipMethod;
            this._shipCompany = shipCompany;
        }

        #endregion

        #region Public Properties

        public virtual Guid Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public virtual decimal RuelRate
        {
            get { return _RuelRate; }
            set { _RuelRate = value; }
        }


        public virtual decimal FromWeight
        {
            get { return _fromWeight; }
            set { _fromWeight = value; }
        }

        public virtual decimal ToWeight
        {
            get { return _toWeight; }
            set { _toWeight = value; }
        }

        public virtual decimal BeginWeight
        {
            get { return _beginWeight; }
            set { _beginWeight = value; }
        }

        public virtual decimal ExtraWeight
        {
            get { return _extraWeight; }
            set { _extraWeight = value; }
        }

        public virtual decimal BeginCost
        {
            get { return _beginCost; }
            set { _beginCost = value; }
        }

        public virtual decimal ExtraCost
        {
            get { return _extraCost; }
            set { _extraCost = value; }
        }

        public virtual decimal ExtraCharge
        {
            get { return _extraCharge; }
            set { _extraCharge = value; }
        }

        public virtual decimal Discount
        {
            get { return _discount; }
            set { _discount = value; }
        }

        public virtual short AreaNumber
        {
            get { return _areaNumber; }
            set { _areaNumber = value; }
        }

        public virtual ShipMethod ShipMethod
        {
            get { return _shipMethod; }
            set { _shipMethod = value; }
        }


        public virtual ShipCompany ShipCompany
        {
            get { return _shipCompany; }
            set { _shipCompany = value; }
        }


        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
        #endregion

        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
            if (!(obj is AreaPrice))
                throw new InvalidCastException("This object is not of type AreaPrice");

            int relativeValue;
            switch (SortExpression)
            {
                case "Id":
                    relativeValue = this.Id.CompareTo(((AreaPrice)obj).Id);
                    break;
                case "FromWeight":
                    relativeValue = this.FromWeight.CompareTo(((AreaPrice)obj).FromWeight);
                    break;
                case "ToWeight":
                    relativeValue = this.ToWeight.CompareTo(((AreaPrice)obj).ToWeight);
                    break;
                case "BeginWeight":
                    relativeValue = this.BeginWeight.CompareTo(((AreaPrice)obj).BeginWeight);
                    break;
                case "ExtraWeight":
                    relativeValue = this.ExtraWeight.CompareTo(((AreaPrice)obj).ExtraWeight);
                    break;
                case "BeginCost":
                    relativeValue = this.BeginCost.CompareTo(((AreaPrice)obj).BeginCost);
                    break;
                case "ExtraCost":
                    relativeValue = this.ExtraCost.CompareTo(((AreaPrice)obj).ExtraCost);
                    break;
                case "ExtraCharge":
                    relativeValue = this.ExtraCharge.CompareTo(((AreaPrice)obj).ExtraCharge);
                    break;
                case "Discount":
                    relativeValue = this.Discount.CompareTo(((AreaPrice)obj).Discount);
                    break;
                case "AreaNumber":
                    relativeValue = (this.AreaNumber != null) ? this.AreaNumber.CompareTo(((AreaPrice)obj).AreaNumber) : -1;
                    break;
                default:
                    goto case "Id";
            }
            if (AreaPrice.SortDirection == SortDirection.Ascending)
                relativeValue *= -1;
            return relativeValue;
        }
        #endregion
    }

    #endregion
}
